package com.xiaoge.libraryuse.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.xiaoge.basedevlibrary.base.GuoBaseActivity;
import com.xiaoge.libraryuse.R;

import ezy.ui.layout.LoadingLayout;

public class LoadingStateActivity extends GuoBaseActivity implements View.OnClickListener {


    private LoadingLayout mVLoading;
    private Button content;
    private Button loading;
    private Button error;
    private Button no_content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);
        initView();

        // 初始化状态布局
        mVLoading = LoadingLayout.wrap(this);

        /*// 显示 content/loading/empty/error 布局
        showContent()
        showLoading()
        showEmpty()
        showError()
        // 设置 loading/empty/error 布局
        setLoading( int resId)
        setEmpty( int resId)
        setError( int resId)
        // 设置空布局的图片与文本
        setEmptyImage( int resId)
        setEmptyText(String value)
        // 设置错误布局的图片与文本，
        setErrorImage( int resId)
        setErrorText(String value)
        // 设置重试按钮文本
        setRetryText(String value)
        // 设置重试按钮的监听回调
        setRetryListener(OnClickListener listener)*/

        mVLoading.setErrorText("出错了");
        mVLoading.setErrorImage(R.mipmap.ic_launcher);

        mVLoading.setEmptyText("数据为空");
        mVLoading.setEmptyImage(R.mipmap.ic_launcher);

        mVLoading.showContent();

    }

    private void initView() {
        content = (Button) findViewById(R.id.content);
        loading = (Button) findViewById(R.id.loading);
        error = (Button) findViewById(R.id.error);
        no_content = (Button) findViewById(R.id.no_content);

        content.setOnClickListener(this);
        loading.setOnClickListener(this);
        error.setOnClickListener(this);
        no_content.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.content:
                mVLoading.showContent();
                break;
            case R.id.loading:
                mVLoading.showLoading();
                break;
            case R.id.error:
                mVLoading.showError();
                break;
            case R.id.no_content:
                mVLoading.showEmpty();
                break;
            default:
                break;
        }
    }
}
